<template>
  <div class="leave">
    <div class="le_con" v-if="total > 0">
      <div class="le_item" v-for="item in data" :key="item.id">
        <div class="le_top">
          <div class="title">留言标题：</div>
          <div class="p_rig">
            <div class="g_lef1">{{ item.title }}</div>
            <div class="g_rig">
              <div class="g_time">{{ item.create_time }}</div>
              <div class="g_icon" style="cursor: pointer" @click="del(item.id)">
                <el-icon><Delete /></el-icon>删除
              </div>
            </div>
          </div>
        </div>
        <div class="le_tet1">
          <div class="title">留言内容：</div>
          <div class="tet">
            {{ item.content }}
          </div>
        </div>
        <div class="le_name">
          <div class="title">是否匿名：</div>
          <div class="sf" v-if="item.user_nickname == ''">是</div>
          <div class="sf" v-else>否</div>
          <!-- <div class="sf" v-else>{{ item.user_nickname }}</div> -->
        </div>
        <div class="le_foot" v-if="item.reply == ''">
          <!-- <div class="title">后台答复：</div> -->
          <!-- <div class="tet" v-if="item.reply == ''"></div>
          <div class="tet" v-else>
            {{ item.reply }}
          </div> -->
        </div>
        <div class="le_foot" v-else>
          <div class="title">后台答复：</div>
          <div class="tet">
            {{ item.reply }}
          </div>
        </div>
        <div class="br"></div>
      </div>
    </div>
    <div class="rq" v-else>
      <img src="@/image/容器.svg" alt="" />
      <div>暂无信息</div>
    </div>
    <div class="con_bom" v-if="total > 0">
      <div class="cc">共{{ total }}条</div>
      <el-pagination
        v-model:page-size="pageSize"
        background
        layout="prev, pager, next"
        :total="total"
        @next-click="nextclick"
        @prev-click="prevclick"
        @change="change1"
      />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { gitmessageApi, getmessagedelApi } from '@/api/user'
const total = ref(10)
let names = ref({
  self: 1,
  page: 1,
  page_size: 3
})
const data = ref()
const gitmessage = () => {
  gitmessageApi(names.value).then(res => {
    console.log(res)
    data.value = res.data.data.data
    total.value = res.data.data.total
  })
}
gitmessage()
const del = (id: any) => {
  getmessagedelApi({ id: id }).then(res => {
    // console.log(res)
    ElMessage({ message: '删除成功', type: 'success' })
    gitmessage()
  })
}
const pageSize = ref(3)
const nextclick = () => {
  names.value.page++
  gitmessage()
}
const prevclick = () => {
  names.value.page--
  gitmessage()
}
const change1 = (e: any) => {
  console.log(e)
  names.value.page = e
  gitmessage()
}
</script>

<style lang="scss" scoped>
.rq {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  // margin-top: 100px;
  padding-top: 100px;
  img {
    width: 228px;
    height: 226px;
  }
}
.leave {
  position: relative;
  height: 1200px;
  margin-top: -18px;
  margin-left: -16px;
  width: 800px;
  background-color: #fff;
  .con_bom {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    .cc {
      width: 60px;
      margin-top: 8px;
    }
  }
  .le_con {
    padding: 16px;
    .le_item {
      .le_foot {
        display: flex;
        .tet {
          word-wrap: break-word;
          width: 640px;
          font-size: 16px;
          color: #e02020;
        }
      }
      .le_name {
        display: flex;
        margin-bottom: 18px;
        .sf {
          font-size: 16px;
          font-weight: 600;
          color: #1a1a1a;
        }
      }
      .le_tet1 {
        margin: 18px 0;
        display: flex;
        .tet {
          word-wrap: break-word;
          width: 640px;
          font-size: 16px;
          color: #1a1a1a;
        }
      }
      .le_top {
        display: flex;
        .p_rig {
          display: flex;
          width: 640px;
          justify-content: space-between;
          .g_lef1 {
            word-wrap: break-word;
            width: 300px;
            font-size: 16px;
            font-weight: 600;
            color: #1a1a1a;
          }
          .g_rig {
            display: flex;
            .g_time {
              margin-right: 40px;
              font-size: 16px;
              color: #1a1a1a;
            }
            .g_icon {
              color: #e02020;
              .el_icon {
                margin-right: 2px;
              }
            }
          }
        }
      }
      .br {
        margin: 17px 0 32px 0;
        border-bottom: 1px solid #e5e5e5;
      }
      .title {
        width: 128px;
        font-size: 16px;
        color: #1a1a1a;
      }
    }
  }
}
</style>
